  import * as echarts from 'echarts'
  const setOption:any = {
    Bar3d(attr:any, data:any, pramas1:any, pramas2:any){
      var colorArr = []
      let space = 4
      let max = parseInt(attr.max)
      let min = parseInt(attr.min)
      let dw = attr.dw
      let p = attr.p
      let pieces = []
      let spitAvg = (Math.abs(max) + Math.abs(min))/5
      let lblFlag = ""
      let priceObj = {}
      var seriesArr = []
      console.log('Bar3d--', attr)
      let color = ['#006E03', '#A0FF00', '#FF0000',  '#64C814',  '#F0F008', '#960000', '#e0f3f8', '#ffffbf', '#fee090']
      for (var i = 0; i < 2; i++) {
        let series = {type: 'bar3D', data: [], symbolSize: 1, barSize: 0.3, shading: 'lambert', sampling: 'average', large: true,
          showSymbol: false, animation: false, label: {fontSize: 12,borderWidth: 1}, emphasis: {label: {show: false}}}
        seriesArr.push(series)
      }
      for(var j=0; j<3; j++) {
        if(min<0){
          lblFlag = j==0? min  + '~ 0' + dw : j==1? '0 ~' + max/2 + dw : j==2? max/2 + '~' + max + dw : ''
          priceObj = { min: j==0?min:j==1?0:j==2?max/2:'', max: j==0?0:j==1?max/2:j==2?max:'', label: lblFlag}
        }else{
          lblFlag = j==2? Math.floor(((j*spitAvg) + min)*100)/100 + dw + '以上' : Math.floor(((j*spitAvg) + min)*100)/100  + '~' + Math.floor(((j+1) * spitAvg + min)*100)/100 + dw
          priceObj = { min: (j*spitAvg) + min, max: j==2? max : ((j+1) * spitAvg + min), label: lblFlag}
        }
        pieces.push(priceObj)
        colorArr.push(color[j])
      }
      let tooltip = { show: true, backgroundColor:'rgba(0,0,0,0.5)', textStyle : {color: '#FFFFFF'},
        formatter: function (params:any) { return '周期：' + params.value[0] + '<br />相位：' + params.value[1] + '°' + '<br />幅值：' + Math.floor(params.value[2]*100)/100 + ' ' + dw }
      }
      let visualMap = { show: true, type: 'piecewise', selectedMode: 'multiple', splitNumber: 6, max: max, itemGap: 0, itemWidth: 14, itemHeight: 20, top:'top', symbol: "rect",                 
        inRange: { symbol: "rect", color: colorArr },
        outOfRange: { symbol: "rect" },
        textStyle: { color: '#2773E6', fontSize: 12 },
        pieces: pieces
      }
      let xAxis3D = { name: ' 周期',type: 'value', nameGap: 30, nameTextStyle: { fontWeight:'bold'}, min:0, max:p, interval: p/space,
        splitLine: { show: true, interval: 'auto', lineStyle: { color: '#2773E6', opacity: 1, width: 1 }},
        axisLabel: { show: true, color: '#0065FF' }
      }
      let yAxis3D = { name: '相位', type: 'value', nameGap: 30, nameTextStyle: { fontWeight:'bold' }, min:0, max:360, interval: 360/space,
        splitLine: { show: true, interval: 'auto', lineStyle: { color: '#2773E6', opacity: 1, width: 1 }},
        axisLabel: { show: true, color: '#0065FF', fontSize: 12, formatter: function (value:any) { return (value + '°');}}
      }
      let zAxis3D = { name: '幅值', type: 'value', nameGap: 40, nameTextStyle: { fontWeight:'bold' }, min: min, max: max, interval: max/5,
        splitLine: { show: true, lineStyle: {color: '#2773E6', opacity: 1, width: 1}},
        axisLabel: { show: true, color: '#0065FF', fontSize: 12, interval: (Math.abs(max) + Math.abs(min)) /2 - 1, formatter: function (value:any) { return value + dw }}
      }
      let grid3D = { show: true, top: -30, boxWidth: 90, boxHeight: 90, boxDepth: 90,
        viewControl: { alpha: 0, beta: 90,rotateSensitivity: 1, zoomSensitivity: 1, panSensitivity: 1, autoRotate: false },
        axisLine: { show: true, interval: 1, lineStyle: { color: '#2773E6', opacity: 0.1, width: 1 }},
        axisTick: { show: false },
        axisPointer: { show: false, lineStyle: { color: 'rgba(39, 115, 230, 1)', opacity: 1, width: 1 },
        label: { show: true, formatter: function (value:any, valueAll:any) {  return '' }, margin: 'auto', color: "#fff",
          borderWidth: 0, borderColor: '#fff', fontFamily: 'sans-serif', fontSize: 12, fontWeight: 'normal'}},
        environment: 'auto',
        light: { main: { intensity: 1.2, shadow: true }, ambient: { intensity: 0.3 } }
      }
      const option = {
        animation: false,
        top: 'top',
        tooltip: tooltip,	
        visualMap: visualMap,
        xAxis3D: xAxis3D,
        yAxis3D: yAxis3D,
        zAxis3D: zAxis3D, 
        grid3D: grid3D,
        series: seriesArr
      };
      return option
    },

    Bar3d_l(attr:any, data:any, pramas1:any, pramas2:any){
      var colorArr = []
      let space = 4
      let max = parseInt(attr.max)
      let min = parseInt(attr.min)
      let dw = attr.dw
      let p = attr.p
      let pieces = []
      let spitAvg = (Math.abs(max) + Math.abs(min))/5
      let lblFlag = ""
      let priceObj = {}
      var seriesArr = []
      let color = ['#006E03', '#A0FF00', '#FF0000',  '#64C814',  '#F0F008', '#960000', '#e0f3f8', '#ffffbf', '#fee090']
      for (var i = 0; i < 2; i++) {
        let series = {type: 'bar3D', data: [], symbolSize: 1, barSize: 0.3, shading: 'lambert', sampling: 'average', large: true,
          showSymbol: false, animation: false, label: {fontSize: 12,borderWidth: 1}, emphasis: {label: {show: false}}}
        seriesArr.push(series)
      }
      for(var j=0; j<3; j++) {
        if(min<0){
          lblFlag = j==0? min  + '~ 0' + dw : j==1? '0 ~' + max/2 + dw : j==2? max/2 + '~' + max + dw : ''
          priceObj = { min: j==0?min:j==1?0:j==2?max/2:'', max: j==0?0:j==1?max/2:j==2?max:'', label: lblFlag}
        }else{
          lblFlag = j==2? Math.floor(((j*spitAvg) + min)*100)/100 + dw + '以上' : Math.floor(((j*spitAvg) + min)*100)/100  + '~' + Math.floor(((j+1) * spitAvg + min)*100)/100 + dw
          priceObj = { min: (j*spitAvg) + min, max: j==2? max : ((j+1) * spitAvg + min), label: lblFlag}
        }
        pieces.push(priceObj)
        colorArr.push(color[j])
      }
      let tooltip = { show: true, backgroundColor:'rgba(0,0,0,0.5)', textStyle : {color: '#FFFFFF'},
        formatter: function (params:any) { return '周期：' + params.value[0] + '<br />相位：' + params.value[1] + '°' + '<br />幅值：' + Math.floor(params.value[2]*100)/100 + ' ' + dw }
      }
      let visualMap = { show: true, type: 'piecewise', selectedMode: 'multiple', splitNumber: 6, max: max, itemGap: 0, itemWidth: 14, itemHeight: 20, top:'top', symbol: "rect",                 
        inRange: { symbol: "rect", color: colorArr },
        outOfRange: { symbol: "rect" },
        textStyle: { color: '#2773E6', fontSize: 12 },
        pieces: pieces
      }
      let xAxis3D = { name: ' 周期',type: 'value', nameGap: 30, nameTextStyle: { fontWeight:'bold'}, min:0, max:p, interval: p/space,
        splitLine: { show: true, interval: 'auto', lineStyle: { color: '#2773E6', opacity: 1, width: 1 }},
        axisLabel: { show: true, color: '#0065FF' }
      }
      let yAxis3D = { name: '相位', type: 'value', nameGap: 30, nameTextStyle: { fontWeight:'bold' }, min:0, max:360, interval: 360/space,
        splitLine: { show: true, interval: 'auto', lineStyle: { color: '#2773E6', opacity: 1, width: 1 }},
        axisLabel: { show: true, color: '#0065FF', fontSize: 12, formatter: function (value:any) { return (value + '°');}}
      }
      let zAxis3D = { name: '幅值', type: 'value', nameGap: 40, nameTextStyle: { fontWeight:'bold' }, min: min, max: max, interval: max/5,
        splitLine: { show: true, lineStyle: {color: '#2773E6', opacity: 1, width: 1}},
        axisLabel: { show: true, color: '#0065FF', fontSize: 12, interval: (Math.abs(max) + Math.abs(min)) /2 - 1, formatter: function (value:any) { return value + dw }}
      }
      let grid3D = { show: true, top: -30, boxWidth: 90, boxHeight: 90, boxDepth: 90,
        viewControl: { alpha: 0, beta: 90,rotateSensitivity: 1, zoomSensitivity: 1, panSensitivity: 1, autoRotate: false },
        axisLine: { show: true, interval: 1, lineStyle: { color: '#2773E6', opacity: 0.1, width: 1 }},
        axisTick: { show: false },
        axisPointer: { show: false, lineStyle: { color: 'rgba(39, 115, 230, 1)', opacity: 1, width: 1 },
        label: { show: true, formatter: function (value:any, valueAll:any) {  return '' }, margin: 'auto', color: "#fff",
          borderWidth: 0, borderColor: '#fff', fontFamily: 'sans-serif', fontSize: 12, fontWeight: 'normal'}},
        environment: 'auto',
        light: { main: { intensity: 1.2, shadow: true }, ambient: { intensity: 0.3 } }
      }
      const option = {
        animation: false,
        top: 'top',
        tooltip: tooltip,	
        visualMap: visualMap,
        xAxis3D: xAxis3D,
        yAxis3D: yAxis3D,
        zAxis3D: zAxis3D, 
        grid3D: grid3D,
        series: seriesArr
      };
      return option
    },

    Bar3d_y(attr:any, data:any, pramas1:any, pramas2:any){
      var colorArr = []
      let space = 4
      let max = parseInt(attr.max)
      let min = parseInt(attr.min)
      let dw = attr.dw
      let p = attr.p
      let pieces = []
      let spitAvg = (Math.abs(max) + Math.abs(min))/5
      let lblFlag = ""
      let priceObj = {}
      var seriesArr = []
      let color = ['#006E03', '#A0FF00', '#FF0000',  '#64C814',  '#F0F008', '#960000', '#e0f3f8', '#ffffbf', '#fee090']
      for (var i = 0; i < 2; i++) {
        let series = {type: 'bar3D', data: [], symbolSize: 1, barSize: 0.3, shading: 'lambert', sampling: 'average', large: true,
          showSymbol: false, animation: false, label: {fontSize: 12,borderWidth: 1}, emphasis: {label: {show: false}}}
        seriesArr.push(series)
      }
      for(var j=0; j<3; j++) {
        if(min<0){
          lblFlag = j==0? min  + '~ 0' + dw : j==1? '0 ~' + max/2 + dw : j==2? max/2 + '~' + max + dw : ''
          priceObj = { min: j==0?min:j==1?0:j==2?max/2:'', max: j==0?0:j==1?max/2:j==2?max:'', label: lblFlag}
        }else{
          lblFlag = j==2? Math.floor(((j*spitAvg) + min)*100)/100 + dw + '以上' : Math.floor(((j*spitAvg) + min)*100)/100  + '~' + Math.floor(((j+1) * spitAvg + min)*100)/100 + dw
          priceObj = { min: (j*spitAvg) + min, max: j==2? max : ((j+1) * spitAvg + min), label: lblFlag}
        }
        pieces.push(priceObj)
        colorArr.push(color[j])
      }
      let tooltip = { show: true, backgroundColor:'rgba(0,0,0,0.5)', textStyle : {color: '#FFFFFF'},
        formatter: function (params:any) { return '周期：' + params.value[0] + '<br />相位：' + params.value[1] + '°' + '<br />幅值：' + Math.floor(params.value[2]*100)/100 + ' ' + dw }
      }
      let visualMap = { show: true, type: 'piecewise', selectedMode: 'multiple', splitNumber: 6, max: max, itemGap: 0, itemWidth: 14, itemHeight: 20, top:'top', symbol: "rect",                 
        inRange: { symbol: "rect", color: colorArr },
        outOfRange: { symbol: "rect" },
        textStyle: { color: '#2773E6', fontSize: 12 },
        pieces: pieces
      }
      let xAxis3D = { name: ' 周期',type: 'value', nameGap: 30, nameTextStyle: { fontWeight:'bold'}, min:0, max:p, interval: p/space,
        splitLine: { show: true, interval: 'auto', lineStyle: { color: '#2773E6', opacity: 1, width: 1 }},
        axisLabel: { show: true, color: '#0065FF' }
      }
      let yAxis3D = { name: '相位', type: 'value', nameGap: 30, nameTextStyle: { fontWeight:'bold' }, min:0, max:360, interval: 360/space,
        splitLine: { show: true, interval: 'auto', lineStyle: { color: '#2773E6', opacity: 1, width: 1 }},
        axisLabel: { show: true, color: '#0065FF', fontSize: 12, formatter: function (value:any) { return (value + '°');}}
      }
      let zAxis3D = { name: '幅值', type: 'value', nameGap: 40, nameTextStyle: { fontWeight:'bold' }, min: min, max: max, interval: max/5,
        splitLine: { show: true, lineStyle: {color: '#2773E6', opacity: 1, width: 1}},
        axisLabel: { show: true, color: '#0065FF', fontSize: 12, interval: (Math.abs(max) + Math.abs(min)) /2 - 1, formatter: function (value:any) { return value + dw }}
      }
      let grid3D = { show: true, top: -30, boxWidth: 90, boxHeight: 90, boxDepth: 90,
        viewControl: { alpha: 0, beta: 90,rotateSensitivity: 1, zoomSensitivity: 1, panSensitivity: 1, autoRotate: false },
        axisLine: { show: true, interval: 1, lineStyle: { color: '#2773E6', opacity: 0.1, width: 1 }},
        axisTick: { show: false },
        axisPointer: { show: false, lineStyle: { color: 'rgba(39, 115, 230, 1)', opacity: 1, width: 1 },
        label: { show: true, formatter: function (value:any, valueAll:any) {  return '' }, margin: 'auto', color: "#fff",
          borderWidth: 0, borderColor: '#fff', fontFamily: 'sans-serif', fontSize: 12, fontWeight: 'normal'}},
        environment: 'auto',
        light: { main: { intensity: 1.2, shadow: true }, ambient: { intensity: 0.3 } }
      }
      const option = {
        animation: false,
        top: 'top',
        tooltip: tooltip,	
        visualMap: visualMap,
        xAxis3D: xAxis3D,
        yAxis3D: yAxis3D,
        zAxis3D: zAxis3D, 
        grid3D: grid3D,
        series: seriesArr
      };
      return option
    },
  }

  // 字体自适应
  const newSize = (res:any) => {
    let clientWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
    if (!clientWidth) return;
    let fontSize = clientWidth / 1920; //设计稿尺寸
    return res * fontSize;  //转换为 rem的布局返回出去
  }

  // 颜色列表
  const colorList = [
    { colorStart:'#0033FF', colorEnd:'#00B7FF' },
    { colorStart:'#9B42FF', colorEnd:'#FF59FC' },
    { colorStart:'#E75F5F', colorEnd:'#FFCD45' },
    { colorStart:'#f7290a', colorEnd:'#f98371' },
    { colorStart:'#CE2B8D', colorEnd:'#FF9595' },
    { colorStart:'#488BFF', colorEnd:'#9abffd' },
    { colorStart:'#26CEBA', colorEnd:'#8efaed' },
    { colorStart:'#FFC069', colorEnd:'#fadfba' },
    { colorStart:'#FD6865', colorEnd:'#f8b2b1' },
    { colorStart:'#becce9', colorEnd:'#82a0df' }
  ]
  export default setOption

